% Copyright 2007 by Marco Barisione
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.

\mode<presentation>

% Use alternative title page style.
\DeclareOptionBeamer{alternativetitlepage}[true]{\def\beamer@fancy@alternativetitlepage{#1}}

% Logo to use in the alternative title page.
\def\beamer@fancy@titlepagelogo{}
\DeclareOptionBeamer{titlepagelogo}{\def\beamer@fancy@titlepagelogo{#1}}

% Bullet shape.
\DeclareOptionBeamer{bullet}{\def\beamer@fancy@bullet{#1}}

\ExecuteOptionsBeamer{alternativetitlepage=false,bullet=square}
\ProcessOptionsBeamer

% Colors.
\setbeamercolor*{lineup}{parent=palette primary}
\setbeamercolor*{linemid}{parent=palette secondary}
\setbeamercolor*{linebottom}{parent=palette tertiary}
\setbeamercolor*{title page header}{parent=palette quaternary}

% Lengths.
\newlength{\beamer@fancy@lineup}
\setlength{\beamer@fancy@lineup}{.025\paperheight}
\newlength{\beamer@fancy@linemid}
\setlength{\beamer@fancy@linemid}{.015\paperheight}
\newlength{\beamer@fancy@linebottom}
\setlength{\beamer@fancy@linebottom}{.01\paperheight}

% Margins.
\newlength{\beamer@fancy@normalmargin}
\setlength{\beamer@fancy@normalmargin}{.06\paperwidth}
\setbeamersize{text margin left=\beamer@fancy@normalmargin}
\setbeamersize{text margin right=\beamer@fancy@normalmargin}
\setlength\leftmargini{.6\beamer@fancy@normalmargin}
\setlength\leftmarginii{.6\beamer@fancy@normalmargin}
\setlength\leftmarginiii{.6\beamer@fancy@normalmargin}

% Normal title page.
\defbeamertemplate*{title page normal}{fancy theme}[1][]
{
  \vbox{}
  \vfill
  \begin{centering}
    \begin{beamercolorbox}[wd=\paperwidth,sep=8pt,center,#1]{title page header}
      \usebeamerfont{title}\inserttitle\par%
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.25em%
        {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
      \fi%     
    \end{beamercolorbox}%
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center,#1]{author}
      \usebeamerfont{author}\insertauthor
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center,#1]{institute}
      \usebeamerfont{institute}\insertinstitute
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center,#1]{date}
      \usebeamerfont{date}\insertdate
    \end{beamercolorbox}\vskip0.5em
    {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
  \end{centering}
  \vfill
}

% Alternative title page, you should use this in a frame with the [plain]
% option.
\defbeamertemplate*{title page alternative}{fancy theme}[1][]
{
  {\parskip0pt\offinterlineskip%
  \hbox{\hskip-\Gm@lmargin\hbox{\vbox{%
  \@tempdima=\textwidth\textwidth=\paperwidth\hsize=\textwidth\def\\{,}\vbox{}\vskip-1.5ex%
    % Title.
    \begin{beamercolorbox}[wd=\paperwidth,ht=.4\paperheight,center,#1]{title page header}
      \usebeamerfont{title}\inserttitle\par%
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.25em%
        {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
      \fi%     
      \vspace{.125\paperheight}%
    \end{beamercolorbox}%
    \vbox{}\vskip-\beamer@fancy@lineup%
    \vbox{}\vskip-\beamer@fancy@linemid%
    % First line.
    \hbox{%
    \begin{beamercolorbox}[wd=.2\paperwidth,ht=\beamer@fancy@lineup,dp=0pt]{}%
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.8\paperwidth,ht=\beamer@fancy@lineup,dp=0pt]{lineup}%
    \end{beamercolorbox}%
    }%
    \vbox{}\vskip0ex%
    % Second line.
    \hbox{%
    \begin{beamercolorbox}[wd=.1\paperwidth,ht=\beamer@fancy@linemid,dp=0pt]{}%
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.9\paperwidth,ht=\beamer@fancy@linemid,dp=0pt]{linemid}%
    \end{beamercolorbox}%
    }%
    % Third line.
    \hbox{%
    \begin{beamercolorbox}[wd=.5\paperwidth,ht=\beamer@fancy@linebottom,dp=0pt]{}%
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.5\paperwidth,ht=\beamer@fancy@linebottom,dp=0pt]{linebottom}%
    \end{beamercolorbox}%
    }%
    \vskip0pt%
  }}%
  \hskip-\Gm@rmargin%
  }}\hfil%
  %
  \begin{columns}
      \ifx\beamer@fancy@titlepagelogo\@empty%
          \column{\textwidth}
      \else
          \column{.5\textwidth}
              % Logo.
              \begin{centering}
                  \vbox{}\vfill
                  \includegraphics[height=.2\paperheight]{\beamer@fancy@titlepagelogo}
                  \vfill
              \end{centering}
          \column{.5\textwidth}
       \fi
          % Authors, institute and date
          \vskip1em\par
          \begin{beamercolorbox}[sep=8pt,center,#1]{author}
            \usebeamerfont{author}\insertauthor
          \end{beamercolorbox}
          \begin{beamercolorbox}[sep=8pt,center,#1]{institute}
            \usebeamerfont{institute}\insertinstitute
          \end{beamercolorbox}
          \begin{beamercolorbox}[sep=8pt,center,#1]{date}
            \usebeamerfont{date}\insertdate
          \end{beamercolorbox}\vskip0.5em
          {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
  \end{columns}
}

\defbeamertemplate*{title page}{fancy}[1][]
{
  \def\beamer@fancy@truetext{true}%
  \ifx\beamer@fancy@alternativetitlepage\beamer@fancy@truetext%
    \usebeamertemplate{title page alternative}%
  \else%
    \usebeamertemplate{title page normal}%
  \fi%
}

% Items.
\defbeamertemplate{itemize item}{squarealt}%
{\tiny\raise.5ex\hbox{\donotcoloroutermaths$\blacksquare$}}
\defbeamertemplate{itemize subitem}{squarealt}%
{\tiny\raise.4ex\hbox{\donotcoloroutermaths$\square$}}
\defbeamertemplate{itemize subsubitem}{squarealt}%
{\tiny\raise.3ex\hbox{\donotcoloroutermaths$\blacksquare$}}

\defbeamertemplate{itemize item}{circlealt}%
{\small\raise.2ex\hbox{\donotcoloroutermaths$\bullet$}}
\defbeamertemplate{itemize subitem}{circlealt}%
{\small\raise.1ex\hbox{\donotcoloroutermaths$\circ$}}
\defbeamertemplate{itemize subsubitem}{circlealt}%
{\scriptsize\raise.1ex\hbox{\donotcoloroutermaths$\bullet$}}

\def\circletext{circle}
\ifx\beamer@fancy@bullet\circletext
  \setbeamertemplate{items}[circlealt]
\else
  \setbeamertemplate{items}[squarealt]
\fi

\mode<all>

